class UserNotifier < ActionMailer::Base
  def signup_notification(user)
    setup_email(user)
    @subject    += 'PISD: Please activate your new account'
    @body[:url]  = "http://grants.pisd.edu/account/activate/#{user.activation_code}"
  end
  
  def activation(user)
    setup_email(user)
    @subject    += 'PISD: Your account is active!'
    @body[:url]  = "http://grants.pisd.edu/"
  end   
  
  def forgot_password(user)
    setup_email(user)
    @subject    += 'PISD: Change your password'
    @body[:url]  = "http://grants.pisd.edu/account/reset_password/#{user.password_reset_code}" 
  end

  def reset_password(user)
    setup_email(user)
    @subject    += 'PISD: Your password has been reset' 
    @body[:url]  = "http://grants.pisd.edu/"
  end
  
  def waiting_approval(user)
    setup_email(user)
    @subject    += 'PISD: Waiting for your approval'  
    @body[:url]  = "http://grants.pisd.edu/"
    @body[:invitation_url]  = "http://grants.pisd.edu/account/accept_invitation/#{user.password_reset_code}" 
  end
  
  def waiting_judges(user)
    setup_email(user)
    @subject    += 'PISD: A grant needs judges assigned' 
    @body[:url]  = "http://grants.pisd.edu/"
  end
  
  def notify_judges(user)
    setup_email(user)
    @subject    += 'PISD: Please score this new grant'  
    @body[:url]  = "http://grants.pisd.edu/"
    @body[:doc_url]  = "http://eforms.pisd.edu/JudgesCoverLetter2007.doc"
    @body[:invitation_url]  = "http://grants.pisd.edu/account/accept_invitation/#{user.password_reset_code}" 
  end
  
  def invitation_notification(user)
    setup_email(user)
    @subject    += 'PISD: You have been invited!'
    @body[:url]  = "http://grants.pisd.edu/account/accept_invitation/#{user.password_reset_code}" 
  end
  
  def notify_not_approved(user)
    setup_email(user)
    @subject    += 'PISD: Application not approved. Requires action.'
    @body[:url]  = "http://grants.pisd.edu/"
  end
  
  protected
  def setup_email(user)
    @recipients  = "#{user.email}"
    @from        = "grantworks@pisd.edu"
    #@from        = "greg.hewett@sbcglobal.net"
    @subject     = "[PISD Grantworks] "
    @sent_on     = Time.now
    @body[:user] = user
  end
end
